/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * priority_queue.java
 *
 * Created on Jun 30, 2010, 3:44:23 PM
 */

package priority_queue;

import java.awt.Color;
import java.util.*;

/**
 *
 * @author sampanng
 */
public class priority_queue extends javax.swing.JFrame {

    //Variables
     Random randnum;//the random number generator
     int rnum;     //the random number created
     int rnum2;      // another random number created
     String message;//message in event field box
     String init_message;//one of the 40 initially generated events
     String new_a_message;//new message for action a
     String new_b_message; // new message for action b
     String len;
     String len2;
     String top_info;
     int top_prinum;
     int prinum;//number in priority field box
     int new_prinum;//number calculated when adding
                       //in random action of a,b or c
     int x; // enabler
     PriorityHeap heap;
    
    public priority_queue() {
        initComponents();
        heap = new PriorityHeap();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jInternalFrame1 = new javax.swing.JInternalFrame();
        event = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        b1 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        start_queue = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        status = new javax.swing.JLabel();
        priority_given = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        priority = new javax.swing.JLabel();
        saved_event = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        abc = new javax.swing.JLabel();
        n_event = new javax.swing.JLabel();
        nname = new javax.swing.JLabel();
        nprinum = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        s1 = new javax.swing.JTextField();
        s2 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jInternalFrame1.setTitle("Priority Queue");
        jInternalFrame1.setMaximumSize(new java.awt.Dimension(1147483647, 2147483647));
        jInternalFrame1.setVisible(true);

        event.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eventActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Lucida Calligraphy", 2, 14));
        jLabel1.setText("EVENT");

        b1.setBackground(new java.awt.Color(204, 204, 255));
        b1.setText("Add Event");
        b1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b1ActionPerformed(evt);
            }
        });

        jLabel2.setText("Priority given to Event");

        start_queue.setBackground(new java.awt.Color(51, 255, 51));
        start_queue.setText("Start Queue");
        start_queue.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                start_queueActionPerformed(evt);
            }
        });

        jLabel3.setText("The event must be 5 characters longs.");

        status.setText("<- Create Event");

        jLabel5.setText("Priority Given (0-200): ");

        jLabel6.setText("Saved Event: ");

        priority.setText("x");

        saved_event.setText("xxxxx");

        jLabel7.setText("Press \"Start\" to start adding to the priority queue.");

        jLabel8.setText("Random action: ");

        abc.setText("a, b or c?");

        n_event.setText("New Event?");

        nname.setText("New Event Name");

        nprinum.setText("New Event Priority");

        jButton1.setBackground(new java.awt.Color(255, 255, 51));
        jButton1.setText("View Log of current Priority Queue");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel9.setText("Current Events in Queue");

        jLabel10.setText("Current Priorities in Queue");

        jLabel11.setText("40 events will be created automatically.");

        jButton2.setBackground(new java.awt.Color(255, 0, 0));
        jButton2.setText("STOP");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jInternalFrame1Layout.createSequentialGroup()
                                        .addComponent(start_queue)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel7))
                                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                        .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jInternalFrame1Layout.createSequentialGroup()
                                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(18, 18, 18)
                                                .addComponent(event))
                                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING))
                                        .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                                .addGap(86, 86, 86)
                                                .addComponent(jLabel5))
                                            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                                .addGap(18, 18, 18)
                                                .addComponent(jLabel11)))))
                                .addGap(4, 4, 4)
                                .addComponent(priority_given, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(nname)
                            .addComponent(nprinum)
                            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                            .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel2)
                                                .addComponent(b1, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel6))
                                            .addGap(7, 7, 7))
                                        .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                            .addComponent(jLabel8)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(abc)))
                                    .addComponent(jLabel9))
                                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(status)
                                    .addComponent(jLabel4)
                                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addComponent(n_event))
                                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                        .addGap(20, 20, 20)
                                        .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(saved_event)
                                            .addComponent(priority, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                        .addGap(59, 59, 59)
                                        .addComponent(jLabel10)))))
                        .addGap(60, 60, 60))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addGap(67, 67, 67)
                        .addComponent(jButton1))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(s1, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                        .addComponent(s2, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(69, 69, 69))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton2)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(start_queue)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(event, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(priority_given, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4)
                    .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(b1)
                        .addComponent(status)))
                .addGap(21, 21, 21)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(saved_event))
                .addGap(18, 18, 18)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(priority))
                .addGap(18, 18, 18)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(abc)
                    .addComponent(n_event))
                .addGap(18, 18, 18)
                .addComponent(nname)
                .addGap(18, 18, 18)
                .addComponent(nprinum)
                .addGap(23, 23, 23)
                .addComponent(jButton1)
                .addGap(31, 31, 31)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10))
                .addGap(18, 18, 18)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(s1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(s2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(38, 38, 38)
                .addComponent(jButton2)
                .addContainerGap(86, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jInternalFrame1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public class PriorityHeap {
        // Tiny subclass for packaging events
        public class PriorityEvent {
            public int PR;
            public String INF;

            PriorityEvent(int newPriority, String newInfo) {
                PR = newPriority;
                INF = newInfo;
            }

            public boolean lessThan(PriorityEvent rh) {
                return PR < rh.PR;
            }
        }

        public PriorityHeap() {
            eventHeap = new Vector<PriorityEvent>();
        }

        // Receive a copy of the source heap so we can save it
        // This really should only be used internally, since otherwise we can't guarantee a proper incoming heap
        private PriorityHeap(Vector<PriorityEvent> source) {
            eventHeap = new Vector<PriorityEvent>(source);
        }

        // Build a new instance using our copy constructor and return it
        public PriorityHeap copy() {
            return new PriorityHeap(eventHeap);
        }

        public void enqueue(int newPriority, String newInfo) {
            // Find the beginning index for the deepest leaf's level
            int index = (int)Math.floor(Math.log((double)eventHeap.size() + 1.0)/Math.log(2.0));
            if (index > 0) {
                index = (int)(Math.pow(2.0, (double)index)) - 1;
            }

            // Find the first empty node, if there is one.
            while (index < eventHeap.size() && eventHeap.get(index) != null) {
                ++index;
            }
            
            int parent = index / 2;
            // Verify space exists and add the new event to the end of the array
            eventHeap.ensureCapacity(index + 1);
            eventHeap.add(new PriorityEvent(newPriority, newInfo));
            // While the event is higher priority than its parent in the heap (sift up)
            while (index > 0 && eventHeap.get(index).lessThan(eventHeap.get(parent))) {
                // Swap the new event into its parent
                PriorityEvent temp = eventHeap.get(parent);
                eventHeap.set(parent, eventHeap.get(index));
                // Swap the parent into the old slot
                eventHeap.set(index, temp);
                index = parent;
                parent = index / 2;
            }
        }

        private void heapify(int rootIndex) {
            int left = 2 * rootIndex + 1;
            int right = 2 * rootIndex + 2;
            int least = rootIndex;

            // Check for higher priority left leaf
            if (eventHeap.size() > left && eventHeap.get(left) != null && eventHeap.get(left).lessThan(eventHeap.get(rootIndex))) {
                least = left;
            }
            // Check for higher priority right leaf
            if (eventHeap.size() > right && eventHeap.get(right) != null && eventHeap.get(right).lessThan(eventHeap.get(least))) {
                least = right;
            }
            // Swap higher priority leaf with root if necessary
            if (least != rootIndex) {
                PriorityEvent temp = eventHeap.get(least);
                eventHeap.set(least, eventHeap.get(rootIndex));
                eventHeap.set(rootIndex, temp);
                heapify(least);
            }
        }

        public void dequeue() {
            // Clear the root element
            eventHeap.set(0, null);

            // Find the last element
            int index = eventHeap.size();
            PriorityEvent end = null;
            while (end == null && index > 0) {
                end = eventHeap.get(--index);
            }

            if (end == null) {
                // No valid element sift down, make sure the queue is empty
                eventHeap.clear();
                return;
            } else {
                // Set last element as root, clear its previous spot
                eventHeap.set(0, end);
                eventHeap.set(index, null);
            }

            // Ensure there is a full level below the deepest leaf
            // Avoids out of bounds exceptions
            // Finds the power of 2 needed to achieve currently used depth and double it for potential capacity
            eventHeap.ensureCapacity((int)Math.pow(2.0, 1.0 + Math.ceil(Math.log((double)index)/Math.log(2.0))));
            
            // Sift down the new root element (heapify)
            // "end" becomes "parent"
            heapify(0);
        }

        public boolean isEmpty() {
            return eventHeap.isEmpty();
        }

        // Returns the highest priority value, -1 otherwise
        public int currentPriority() {
            if (!isEmpty()) {
                return eventHeap.firstElement().PR;
            } else {
                return -1;
            }
        }

        // Returns the highest priority info, null otherwise
        public String currentInfo() {
            if (!isEmpty()) {
                return eventHeap.firstElement().INF;
            } else {
                return null;
            }
        }

        public int size(){
            return eventHeap.size();
        }

        private Vector<PriorityEvent> eventHeap;
    }

    private void start_queueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_start_queueActionPerformed
        x = 6;//enables Create Event Button
        start_queue.setEnabled(false);//disables start button from being
                                        // pressed again.
        for (int z = 1; z < 10; z = z + 1) {
            init_message = "act0" + z;
            randnum = new Random();//creates new random generator
            rnum2 = randnum.nextInt(50)+ 1;//creates a random number from 0 to 50     
            heap.enqueue(rnum2, init_message);

        }
        for (int h = 10; h < 41; h = h + 1) {
            init_message = "act" + h;
            randnum = new Random();//creates new random generator
            rnum2 = randnum.nextInt(51);//creates a random number from 0 to 50
            heap.enqueue(rnum2, init_message);
        }

}//GEN-LAST:event_start_queueActionPerformed

    private void b1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b1ActionPerformed

        if (x != 6){
            message1("must first 'Start' the program");
            return;
        }

        message = event.getText();//gets text from event

        int messagelength = message.length(); //finds length of message
        if (messagelength != 5){//if the length of the message is no 5
            event.setBackground(Color.PINK);//changes field box to pink
            message1("Event must contain 5 Characters!");//prints error
            return;//exits action of button
        }
        event.setBackground(Color.WHITE);
        try{
            prinum = (Integer.parseInt(String.valueOf(priority_given.getText())));
        }//if the priority field box is not a number
        catch (Exception e) {
            priority_given.setBackground(Color.PINK);//Error
            message1("Priority must be an integer between 0 and 200");//prints error
            return;//exits action of button
        }
        if (prinum < 1 || prinum > 200){//if prinum is not between 0 and 200
            priority_given.setBackground(Color.PINK);//Error
            message1("Priority must be an integer between 0 and 200");//Print error
            return;//exit funtion
        }
        priority_given.setBackground(Color.WHITE);
        randnum = new Random();//creates new random generator
        rnum = randnum.nextInt(10);//creates a random number from 0 to 9
        message1("<- Create Event");//changes to original message if it was
                                     //changed
        saved_event.setText((String.valueOf(message)));//shows what was saved
        priority.setText((String.valueOf(prinum)));//shows what was saved

        heap.enqueue((int)prinum, message);
        if (rnum < 5){//for random number less than 5 (50% chance of occurence)
            abc.setText("a");//changes label so user knows what happened
            n_event.setText("New Event created");//changes label so user
                                                //knows what happened
            new_a_message = "new_a-"+message;
            nname.setText(new_a_message);
            new_prinum = prinum + prinum*3;//new priority is given for
                                            //appropriate event
            nprinum.setText(String.valueOf(new_prinum));//prints new priority

            heap.enqueue(new_prinum, new_a_message);
        }
        if (rnum > 4 && rnum < 8){//for random number between 5 and 7
                                    //(30% chance of occurence)
            abc.setText("b");//changes label so user knows what happened
            n_event.setText("New Event created");
            new_b_message = "new_b-"+message;
            nname.setText(new_b_message);

            new_prinum = prinum + prinum*10; //new priority is given for
                                            //appropriate event
            nprinum.setText(String.valueOf(new_prinum));//prints new priority

            heap.enqueue(new_prinum, new_b_message);
        }
        if (rnum > 7){//for random number more than 8 (20% chance of occurence)
            abc.setText("c");//changes label so user knows what happened
            n_event.setText("No new Event created");
            nname.setText("N/A");
            nprinum.setText("N/A");
        }
    }//GEN-LAST:event_b1ActionPerformed

    private void eventActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eventActionPerformed

    }//GEN-LAST:event_eventActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        b1.setEnabled(false);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        s1.setText("");
        s2.setText("");
        PriorityHeap temp = heap.copy();
        while (!temp.isEmpty()) {
            s1.setText(s1.getText() + ", " + temp.currentInfo());
            s2.setText(s2.getText() + ", " + temp.currentPriority());
            temp.dequeue();
        }
        /*
        short y = 0;
        int i = -1;
        s1.setText("");
        s2.setText("");
        while(y == 0) {
            i += 1;
            int indexer = heap.getlength();
            if (i == indexer){
                y = 6;//while loop ends when heap is empty
            }
           s1.setText(s1.getText() + ", " + heap.displayINF(i));
           s2.setText(s2.getText() + ", " + heap.displayPR(i));
        }
        */
    }//GEN-LAST:event_jButton1ActionPerformed
    private void message1(String msg) {//changes String of "Create Event" label
        status.setText(msg);
    }


    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new priority_queue().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel abc;
    private javax.swing.JButton b1;
    private javax.swing.JTextField event;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel n_event;
    private javax.swing.JLabel nname;
    private javax.swing.JLabel nprinum;
    private javax.swing.JLabel priority;
    private javax.swing.JTextField priority_given;
    private javax.swing.JTextField s1;
    private javax.swing.JTextField s2;
    private javax.swing.JLabel saved_event;
    private javax.swing.JButton start_queue;
    private javax.swing.JLabel status;
    // End of variables declaration//GEN-END:variables

}
